﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CRM.Database.Model.Customers>" %>
<%@ Import Namespace="CRM.Resourses" %>

<% Html.DevExpress().GridView(settings =>
                                    {
                                        settings.Name = "gdContacts";
                                        settings.KeyFieldName = "IdContact";

                                        settings.Settings.ShowGroupPanel = true;
                                        settings.Settings.ShowFilterRow = true;

                                        settings.CallbackRouteValues =
                                          new { Controller = "Customers", Action = "CustomerAddressesAndContacts_Contacts_Callback", customerId = Model.IdCustomer };
                                        settings.SettingsPager.PageSize = 20;
                                        settings.Width = Unit.Percentage(100);
                                        
                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.Caption = Resourses.customerName1;
                                                                     column.FieldName = "Name";
                                                                 });
                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.Caption = Resourses.customerLegalEntity;
                                                                     column.FieldName = "LegalEntities.Name";
                                                                     column.ColumnType = MVCxGridViewColumnType.ComboBox;

                                                                     var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                                                     if (comboBoxProperties != null)
                                                                     {

                                                                         comboBoxProperties.DataSource =
                                                                             Model.LegalEntities;
                                                                         comboBoxProperties.TextField = "Name";
                                                                         comboBoxProperties.ValueField = "IdLegalEntity";
                                                                         comboBoxProperties.ValueType = typeof(int);
                                                                     }
                                                                     
                                                                 });
                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.Caption = Resourses.customerPosition;
                                                                     column.FieldName = "Position";
                                                                 });
                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.Caption = Resourses.customerPhone;
                                                                     column.FieldName = "Phone";
                                                                 });
                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.Caption = "Email";
                                                                     column.FieldName = "Email";
                                                                 });
                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.Caption = Resourses.customerBirthday;
                                                                     column.FieldName = "Birthday";
                                                                     column.ColumnType = MVCxGridViewColumnType.DateEdit;
                                                                 });
                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.Caption = Resourses.customerRemind;
                                                                     column.FieldName = "Remind";
                                                                     column.ColumnType = MVCxGridViewColumnType.CheckBox;
                                                                 });
                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.Caption = Resourses.customerComments;
                                                                     column.FieldName = "Comments";
                                                                 });

                                    }

    ).Bind(Model.Contacts).GetHtml();%>